﻿using System;
using System.Linq;
using System.Web.UI.WebControls;
using Ones.ServiceHumanResourceManagement;

namespace Ones.SysAdmin
{
    public partial class HrListDivJobPage : System.Web.UI.Page
    {
        private ServiceHumanResourceManagementClient c = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadDiv();
                loadJob();
            }
        }

        public void rptDiv_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Session.Add("cmd", e.CommandName);
            Session.Add("id", e.CommandArgument);

            Response.Redirect("~/SysAdmin/HrMgmtDivPage.aspx");
        }

        public void rptJob_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Session.Add("cmd", e.CommandName);
            Session.Add("id", e.CommandArgument);

            Response.Redirect("~/SysAdmin/HrMgmtJobPage.aspx");
        }

        private void loadDiv()
        {
            c = new ServiceHumanResourceManagementClient("hrBasicHttpBinding");

            rptDiv.DataSource = c.searchAllDivisions();
            rptDiv.DataBind();

            c.Close();
        }

        private void loadJob()
        {
            c = new ServiceHumanResourceManagementClient("hrBasicHttpBinding");

            rptJob.DataSource = c.searchAllJobs();
            rptJob.DataBind();

            c.Close();
        }
    }
}